package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.ArticleDAO;

import entity.Article;



/**
 * Servlet to manage article
 */
@WebServlet("/ManageServlet")
public class ManageServlet extends HttpServlet {
	
    private ArticleDAO articleDAO = ArticleDAO.getInstance(); 
    /**
     * @see HttpServlet#HttpServlet()
     */
    protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html; charset=UTF-8");

		int total = articleDAO.getTotal();
        int start = 0;
		

		List<Article> articles = articleDAO.list(start, total);
			
		//System.out.println("articles.size():"+articles.size());
		//System.out.println("articles.size():"+articles.get(2).getArticle_istop());
		request.setAttribute("articles", articles);

		request.getRequestDispatcher("Article.jsp").forward(request, response);
		

	}



}
